/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package estate;

import java.util.ArrayList;
import java.util.List;

enum UserTypes { normal, admin, worker, agent, company }     //etc.

/**
 *
 * @author gacek
 */


public class User extends Object 
                  implements java.lang.Comparable
{
    private String login;
    private String Pesel;
    private String password;
    private String name;    // imię i nazwisko/nazwa firmy deweloperskiej //proponuje zrobic dwa osobne pola, wtedy moznaby wyswietlic np: Witaj, Bożena (na stronce).
    private String street;
    private String houseNr;
    private String postCode;
    private String city;

    public String getPesel() {
        return Pesel;
    }

    public void setPesel(String Pesel) {
        this.Pesel = Pesel;
    }
    private String mail;
    private String phone;
    private String nip;
    private String regon;
    private String additionalInf;   // informacje dodatkowe
    private UserTypes userType;
    private ArrayList<Estate> kolekcjaEstate=new ArrayList<Estate>();

    public String getLogin(){return login;}
    public void setLogin(String log){login=log;}
    public String getPassword(){return password;}
    public void setPassword(String pass){password=pass;}
    public String getName(){return name;}
    public void setName(String nam){name=nam;}
    public String getStreet(){return street;}
    public void setStreet(String str){street=str;}
    public String getHouseNr(){return houseNr;}
    public void setHouseNr(String house){houseNr=house;}
    public String getPostCode(){return postCode;}
    public void setPostCode(String postC){postCode=postC;}
    public String getCity(){return city;}
    public void setCity(String c){city=c;}
    public String getMail(){return mail;}
    public void setMail(String m){mail=m;}
    public String getPhone(){return phone;}
    public void setPhone(String ph){phone=ph;}
    public String getNIP(){return nip;}
    public void setNIP(String n){ 
        if(this.userType.equals(UserTypes.company))
        {
            nip=null;
        }else{
            nip=n;
        }
    }
    public String getRegon(){return regon;}
    public void setRegon(String r){
        if(this.userType.equals(UserTypes.company))
        {
            regon=r;
        }else{
            regon=null;
        }
    }
    public String getAdditionalInf(){return additionalInf;}
    public void setAdditionalInf(String ad){additionalInf=ad;}
    public UserTypes getUserType(){return userType;}
    public void setUserTypes(UserTypes a){userType=a;}

    /*atrapa compareTo*/
    public int compareTo(Object o)
    {
        return 0;
    }

    /*atrapa equalsa*/
    @Override
    public boolean equals(Object o)
    {  return Pesel.equals(((User)o).getPesel());
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 53 * hash + (this.login != null ? this.login.hashCode() : 0);
        hash = 53 * hash + (this.Pesel != null ? this.Pesel.hashCode() : 0);
        hash = 53 * hash + (this.password != null ? this.password.hashCode() : 0);
        hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 53 * hash + (this.street != null ? this.street.hashCode() : 0);
        hash = 53 * hash + (this.houseNr != null ? this.houseNr.hashCode() : 0);
        hash = 53 * hash + (this.postCode != null ? this.postCode.hashCode() : 0);
        hash = 53 * hash + (this.city != null ? this.city.hashCode() : 0);
        hash = 53 * hash + (this.mail != null ? this.mail.hashCode() : 0);
        hash = 53 * hash + (this.phone != null ? this.phone.hashCode() : 0);
        hash = 53 * hash + (this.nip != null ? this.nip.hashCode() : 0);
        hash = 53 * hash + (this.additionalInf != null ? this.additionalInf.hashCode() : 0);
        return hash;
    }



    @Override
    public String toString()
    { String pom;
      pom= "1: "+login+" 2: "+password+" 3: "+name+" 4: "+name+" 5: "+street+
              " 6: "+houseNr+" 7: "+postCode+" 7: "+city+" 8: "+mail+
              " 9: "+phone+" 10: "+nip+" 11: "+regon+" 12: "+additionalInf+
              " 13: "+userType+" 14: "+Pesel;
      return pom;
    }

    public void addEstate(Estate estate)
    {
        kolekcjaEstate.add(estate);
    }


	/* BEGIN Funkcjonalnosć komentarzy */

	private List<Comment> komentarze = new ArrayList<Comment>();

	public List<Comment> getKomentarze()
	{
		return this.komentarze;
	}

	public void addKomentarz(Comment tmp)
	{
		this.komentarze.add(tmp);
	}

	/* END Funkcjonalnosć komentarzy */

}
